package com.wu.springcloud.controller;

import com.wu.springcloud.pojo.Dept;
import com.wu.springcloud.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 武爸爸
 * @create 2020-09-27 0:31
 */
@RestController
public class DeptConsumerController {

     //理解： 消费者不应该有 service层

    @Autowired
    private DeptClientService service = null;  //  = null;   没有实现类  所以为null


    @RequestMapping("/consumer/dept/add")
    public boolean add(Dept dept){
        return this.service.addDept(dept);
    }

    @RequestMapping("/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id){
        return this.service.queryById(id);
    }

    @RequestMapping("/consumer/dept/list")
    public List<Dept> list(){
        return this.service.queryAll();
    }

}
